package com.itheima.health.jobs;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.health.service.OrderSettingService;
import lombok.extern.slf4j.Slf4j;

import java.util.Calendar;
import java.util.Date;

@Slf4j
public class ClearOrderSettingJob {

    @Reference
    private OrderSettingService orderSettingService;

    /**
     * 每个月的最后一天凌晨两点删除之前的数据
     */
    public void clearOrderSettingJob(){
        log.info("[定时删除OrderSetting过期数据开始]");
        //获取当前时间

        Calendar today = Calendar.getInstance();

        today.set(Calendar.HOUR_OF_DAY,0);
        today.set(Calendar.MINUTE,0);
        today.set(Calendar.SECOND,0);
        today.set(Calendar.MILLISECOND,0);

        // Date today = new Date();
        //删除数据
        orderSettingService.clearJopByDate(today.getTime());
        log.info("[定时删除OrderSetting过期数据结束]");
    }

}
